import permision from "@/common/permission.js"
import loading from '@/components/xuan-loading/xuan-loading.vue'
import cLabel from "@/components/cat-label/cat-label.vue"
import fromItem from '@/components/from-item/from-item.vue'
import titles from '@/components/titles/index.vue';
import phbTable from '@/components/phb-table/index.vue';
import lsjUpload from '@/uni_modules/lsj-upload/components/lsj-upload/lsj-upload.vue';
import datetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue';
import cc from "./new_file.vue"

import tree from '@/components/tki-tree/tki-tree' //树结构
import wbstree from '@/components/treeData/wbsTree/sevenq-lazy-tree' //wbs
import uniTag from '@/components/uni-tag/uni-tag.vue';
import uniDataCheckbox from '@/components/uni-data-checkbox/uni-data-checkbox.vue'
// import multipleSelect from "@/components/multiple-select/multiple-select";

import wx from "weixin-js-sdk";
var maxNum = 6;
// 选择相机还是文件
var sourceType = [
	['camera'],
	['album'],
	['camera', 'album']
]
// 类型压缩还是原文件
var sizeType = [
	['compressed'],
	['original'],
	['compressed', 'original']
]

export default {
	components: {
		loading,
		cLabel,
		fromItem,
		titles,
		phbTable,
		lsjUpload,
		cc,
		datetimePicker,
		tree, //树结构
		wbstree,
		uniTag,
		uniDataCheckbox,
		// multipleSelect,//龄期多选
	},
	data() {
		return {
			showdialog: false,
			scanQRCode: null, //试件编码
			// 变动
			Checktypenum: "0", //保存时传取样类型  0自检1外委
			ChecktypenumList: [{
					label: "自检取样",
					value: "0"
				},
				{
					label: "外委取样",
					value: "1"
				}
			], //取样类型
			formObjText_zj: 0, //取样列表页显示详情
			fSamplespecsList: [], //规格型号
			ManufacturerList: [], //生产厂家
			fStrengthgradeList: [], //品种等级、强度等级
			fStrengthgradeText: null, //fStrengthgrade对应的标题显示
			fSamplenoList: [], //沥青标号
			fSamplenoText: null, //fSampleno对应的标题显示
			fDiameterList: [], //钢筋直径
			fTesttypeList: [], //钢筋种类、混凝土种类
			fTesttypeText: null, //fTesttype对应的标题显示
			fMixingmethodList: [], //搅拌方式
			fWareconditionList: [], //养护条件
			fProductiondatesText: null, //fProductiondates对应的标题显示
			fSpecimenageList: [], //养护龄期
			fSpecimensizeList: [], //试件尺寸
			BusinessscopenameList: [], //取样标段下拉框
			// 外委
			fSamplespecs: true,
			// 外委

			fromMsg: {
				fId: "", //传fid表示修改 不传表示新增
				userId: "", //当前登录人id
				userName: "", //当前登录人姓名
				fCompanyid: "", //施工单位id 隐藏
				fCompanyname: "", //施工单位名称 隐藏
				fProjectid: "", //项目id 隐藏
				fProjectname: "", //项目名称 隐藏
				fChecktypenum: "", //0自检1外委
				fChecktype: "", //检测类型  施工自检,施工外委/监理抽检,监理外委
				fEntryledgerid: "", //材料进场编号id 隐藏
				fEntrynumber: "", //材料进场编号
				fMaterialtypeid: "", //材料进场材料种类id
				fSamplenostr: "", //取样编号
				fSampletype: "", //样品种类id 隐藏
				fSampletypename: "", //样品种类汉字
				fVarietyid: "",
				fSamplemodel: "", //样品编码
				fSamplespecs: "", //样品规格
				fSamplemessage: "", //样品描述
				fBusinessscopename: "", //取样标段 companyId
				fBusinessscopecompanyid: "", //取样标段 companyId
				fSamplename: "", //样品名称
				fDeputynum: "", //代表数量
				fSampleno: "", //生产批号  沥青标号  出厂编号
				fTesttype: "", //沥青种类  钢筋种类 混凝土种类  砂浆种类 钢筋种类
				fSampletestpiece: "", //试件编号
				fStrengthgrade: "", //品种等级 品种强度等级 强度等级
				fSpecimenage: "", //养护龄期  
				// SpecimenageList: [], //养护龄期--页面展示
				fSpecimensize: "", //试件尺寸  
				fProductiondate: "", //制件日期  生产日期
				fProductiondates: "", //制件日期  
				fBrand: " ", //牌号   
				fDiameter: "", //直径	  
				fManufacturer: "", //生产厂家
				fPlace: "", //产地
				fAddress: "", //取样地点
				fProjectlocation: "", //工程部位/用途
				fProjectlocationid: '', //工程部位/用途id
				fApproachdates: "", //进场日期
				fSampledates: "", //取样日期
				fSampleperson: "", //取样人
				fSamplepersonid: "", //取样人id
				fWitnessperson: "", //见证人
				fNote: "", //备注
				fLon: "", //经度
				fLat: "", //纬度
				recordfiles: [], //删除文件id集合
				fPhotofile: "", //取样现场照片id
				fSourcefile: "", //现场取样视频件id
				fSamplenum: "", //外加剂掺量
				fMixingmethod: "", //搅拌方式
				fWarecondition: "", //养护条件
				fTestlayer: "", //试验层位
				fGradationtype: "", //级配类型
				isSubmit: "0", //0 保存 1提交
			}, //参数
			// 变动




			inverted: false, //扫码
			// TesttypeList: ["==请选择=="],
			// TesttypeList1: ["==请选择==", '硬化后水泥混凝土', '硬化后水泥砂浆', '硬化后水泥净浆'], //试件类型
			// TesttypeList2: ["==请选择==", '钢筋试件'], //试件类型
			fMaterialindex: -1, //材料进场
			fSampletypeindex: -1, //样品种类
			materialShow: false, //材料进场编号是否有值
			disabledNumber: false, //根据材料进场编号有无    控制  表单部分是否可编制
			flagNum: 0, //下拉框/时间表单  0可填  -1不可填

			files: [],
			appliance: null,
			start: Date.now() - 5000 * 24 * 3600000,
			end: Date.now() + 5000 * 24 * 3600000,

			isgoText: true,
			recordInfo: [],

			count: 8,
			heights: '156rpx',
			option: {},
			debug: true,
			size: 10,
			// 选择文件后是否立即自动上传
			instantly: true,
			userCompanyTree: [
				"强度等级", "C10", "C15",
				"C20", "C25", "C30", "C30", "C35", "C40",
				"C45", "C50", "C55", "C60", "C65", "C70",
				"C75", "C80", "C85", "其他"
			],
			Chargeusername: [], //责任人姓名
			sampleTypesq: {},

			// loading样式
			width: '150rpx',
			height: '100rpx',
			shadeShow: false,
			backgroundColor: "transparent",
			themeColor: '#33CCCC',
			// loading样式

			type: '',
			data: {},
			clickN: 0,
			detatilId: "",
			iconpath: require("@/static/position.png"),
			isSrc: require("@/static/down.png"),
			contentShow: true,
			src: "", //视频存放
			sourceType: ['拍摄', '相册'],
			sizeType: ['压缩', '原图', '压缩或原图'],
			canAdd: true,
			videosourceType: ['拍摄', '相册'],

			cameraList: [{
					value: 'back',
					name: '后置摄像头',
					checked: 'true'
				},
				{
					value: 'front',
					name: '前置摄像头'
				}
			],
			cameraIndex: 0,
			Inv: 0,
			// 新增
			num: 1,
			title: 'map',
			latitude: "",
			longitude: "",
			scale: 8,
			markers: [],
			page: false,
			index: -1,
			modalName: null,
			pieceName: null,
			// 日期
			date: "",
			// 进度条
			pgList: 0,
			click: "",

			fileList: [],

			materialList: [],
			userInfo: {
				projectId: "",
			},
			// 图片预览数组
			previewImg: [],
			flag: 0,
			ze: [],
			cde: [],


			// 四川
			token: "",
			// show: false, //是否显示 - 双向绑定
			// 四川


			// 弹框树结构--样品种类
			selectParent: false,
			multiple: false,
			companyTree: [],
			flod: true,
			// 弹框树结构--样品种类

			// 上传照片/视频
			fastImgLists: [],
			imgList: [],
			fOnworkfile: "", //取样现场照片
			oPhotoList: [],
			oPhotoList1: [],
			// 上传照片/视频

			// 连续扫码
			APPlist: [],
			// 连续扫码


			// 龄期
			SpecimenAgeData: {
				value: -1,
				fSpecimenage: [-1]
			},
			// SpecimenAgeList: [], //试件龄期下拉框内容
			fSpecimenageindex: -1,
			defaultSelected: [], //默认选中项
			// 龄期


			timeId: null,


			// wbs
			formData: {
				name: "",
			},
			header: {
				Authorization: uni.getStorageSync('token'),
			},
			success: ["data"],
			wbsRowData: null,
			wbsUrlFrom: {
				fCompanyid: "", //标段id 必填
				projectId: "", //项目id 
				parentId: -1 //父级id 第一级传-1  子级取上一级fId或fNodeid 必填
			},
			// wbs

			isScanCode: false,
			isLock: true
		};
	},
	// onNavigationBarButtonTap(e) {
	// 	var that = this
	// 	if (this.scanQRCode != null) {
	// 		this.scanCode(this.scanQRCode)
	// 	} else {
	// 		uni.showToast({
	// 			title: "请先填写试件数量",
	// 			icon: 'none',
	// 			duration: 2000
	// 		});
	// 	}
	// },
	onNavigationBarButtonTap(e) {
		var that = this

		if (this.fromMsg.fSampletypename == '') {
			uni.showToast({
				title: "请先选择样品种类",
				icon: 'none',
				duration: 2000
			});
		} else {


			if (this.fromMsg.fSampletypename == "钢筋原材" ||
				this.fromMsg.fSampletypename == "钢筋焊接" ||
				this.fromMsg.fSampletypename == "钢筋机械连接" ||
				this.fromMsg.fSampletypename == "硬化后水泥混凝土" ||
				this.fromMsg.fSampletypename == "硬化后水泥砂浆" ||
				this.fromMsg.fSampletypename == "硬化后水泥净浆" ||
				this.fromMsg.fSampletypename == "水泥混凝土抗弯拉" ||
				this.fromMsg.fSampletypename == "水泥抗折抗压强度"
			) {
				if (this.scanQRCode != null) {
					this.scanCode(this.scanQRCode)
				} else {
					uni.showToast({
						title: "请先填写试件数量",
						icon: 'none',
						duration: 2000
					});
				}
			} else {
				uni.showToast({
					title: "当前样品种类不可扫码",
					icon: 'none',
					duration: 2000
				});
			}
		}
	},
	watch: {
		showdialog(newVal, oldVal) {
			if (newVal == true) {
				// ("example")[0]
				let cssStr = "overflow-y: hidden; height: 100%;";
				document.getElementsByClassName('formPage')[0].style.cssText = cssStr;
				document.body.style.cssText = cssStr;
			} else {
				let cssStr = "overflow-y: auto; height: auto;";
				document.getElementsByClassName('formPage')[0].style.cssText = cssStr;
				document.body.style.cssText = cssStr;
			}

			// 下面需要这两行代码，兼容不同浏览器
			document.body.scrollTop = this.pageScrollYoffset;
			window.scroll(0, this.pageScrollYoffset);
		}
	},
	onShow() {},
	onLoad(options) {
		var that = this;
		uni.getStorage({
			key: 'userInfo',
			success: function(res) {
				that.userInfo = JSON.parse(res.data);
				that.getfSampletypeFun(that.userInfo.companyId,
					that.userInfo.userId);
				that.getTree(); //取样标段
				that.wbsUrlFrom = {
					// fCompanyid: "cd5d6ddc-8fe3-4995-95a7-c68c6309cdd2", //云检的标段Id
					fCompanyid: that.userInfo.companyId, //标段id 必填
					projectId: "", //项目id 必填
					parentId: -1 //父级id 第一级传-1  子级取上一级fId或fNodeid 必填
				}
			}
		})

		if (options.type === 'add') {
			// 新增
			this.type = 'add';
			this.fromMsg.fId = '';
			this.addInfoMsg()
			//获取定位经纬度
			// #ifdef H5
			that.getaaa()
			// #endif
			//获取定位经纬度
		} else if (options.id) {
			// 编辑 
			this.detatilId = options.id;
			this.type = 'edit';
			this.fromMsg.fId = options.id
			this.getInfoMsg(options.id)
		}
		this.timeing = new Date().getTime();
		// this.getDate();

		// #ifdef APP-PLUS
		this.playVideo()
		uni.$on('submit-page', (data) => {
			that.clickNum(data)
		})
		// #endif
		// #ifdef H5
		this.appliance = 1
		// #endif

	},

	// onUnload() {
	// 	uni.$off('submit-page')
	// },
	onReady() {},
	onUnload() {
		this.src = '',
			this.sourceTypeIndex = 0,
			this.sourceType = ['拍摄', '相册', '拍摄或相册'];
		// this.sizeType = ['压缩', '原图', '压缩或原图'],
		uni.$off('drawer-page')
	},

	// 返回
	onBackPress(event) {
		uni.navigateTo({
			url: "/pages/apply/sampleManage/fieldSampling/testing/index"
		});

		return true;
	},

	methods: {
		// 材料编号带参数
		otherFun(object) {
			if (!!object) {
				this.disabledNumber = true;
				this.fromMsg.fEntryledgerid = object.fId; //材料进场编号id 隐藏
				this.fromMsg.fEntrynumber = object.fEntrynumber; //材料进场编号
				this.fromMsg.fMaterialtypeid = object.fMaterialtypeid; //材料进场材料种类id
				this.fromMsg.fSamplespecs = object.fSpecification; //规格型号

				if (object.fCompanyname == "" && object.fCompanyname == null) {
					that.fromMsg.fBusinessscopename = this.userInfo.companyName; //取样标段
					that.fromMsg.fBusinessscopecompanyid = this.userInfo.companyId;
				} else {
					this.fromMsg.fBusinessscopename = object.fCompanyname; //取样标段
					this.fromMsg.fBusinessscopecompanyid = object.fCompanyid;
				}

				this.fromMsg.fSampleno = object.fBatchnumber; //批号/编号
				this.fromMsg.fManufacturer = object.fManufacturername; //生产厂家
				this.fromMsg.fApproachdates = object.fEntrydates; //进场日期
				this.getfSampletypeFun();
			}
		},




		// 预新增请求接口
		addInfoMsg() {
			this.$http.getSampleWorkByAdd({
				fProjectid: this.userInfo.projectId, //当前登录人项目id
				fCompanyid: this.userInfo.companyId, //当前登录人机构id
				fNature: this.userInfo.companyNature,
			}).then(res => {
				if (res.errcode == 0) {
					var that = this;
					that.fromMsg = res.data.lrCheckSample;
					that.Checktypenum = "0"; //0自检1外委
					that.fromMsg.userId = that.userInfo.userId; //当前登录人id
					that.fromMsg.userName = that.userInfo.realName; //当前登录人姓名
					that.fromMsg.fCompanyid = that.userInfo.companyId; //施工单位id 隐藏
					that.fromMsg.fCompanyname = that.userInfo.companyName; //施工单位名称 隐藏
					that.fromMsg.fProjectid = that.userInfo.projectId; //项目id 隐藏
					that.fromMsg.fProjectname = that.userInfo.projectName; //项目名称 隐藏
					that.fromMsg.fChecktypenum = "0"; //项目名称 隐藏
					that.fromMsg.fChecktype = "自检取样"; //项目名称 隐藏
					that.fromMsg.fBusinessscopename = that.userInfo.companyName; //取样标段
					that.fromMsg.fBusinessscopecompanyid = that.userInfo.companyId;
					that.fromMsg.fSampleperson = that.userInfo.realName; //取样人
					that.fromMsg.fSamplepersonid = that.userInfo.userId; //取样人id
					this.getfSampletypeFun();
				} else {
					uni.showToast({
						title: "获取预新增数据失败",
						icon: 'none',
						duration: 2000
					});
				}
			}, (err) => {
				uni.showToast({
					title: "获取预新增数据失败",
					icon: 'none',
					duration: 2000
				});
			});
		},
		// 详情接口
		getInfoMsg(id) {
			this.$http.getSampleWorkByFid({
				fId: id, //数据id
			}).then(res => {
				if (res.errcode == 0) {
					var that = this;
					that.fromMsg = res.data.lrCheckSample;
					var data = res.data.lrCheckSample
					this.fSampletypeindex = 0;
					this.getPurveyorData(data.fVarietyid); //生产厂家下拉框list
					// 进场材料编号
					if (that.fromMsg.fEntrynumber == "" || that.fromMsg.fEntrynumber == null) {
						that.disabledNumber = false;
					} else {
						that.disabledNumber = true;
					}
					//取样标段
					if (that.fromMsg.fBusinessscopename == "" || that.fromMsg.fBusinessscopename == null) {
						that.fromMsg.fBusinessscopename = this.userInfo.companyName;
					}

					// 见证人
					if (that.fromMsg.fSampleperson == "" || that.fromMsg.fSampleperson == null) {
						that.fromMsg.fSampleperson = that.userInfo.realName; //取样人
						that.fromMsg.fSamplepersonid = that.userInfo.userId; //取样人id
					}
					// 照片
					var photo = res.data.fPhotofileList
					photo.map((item) => {
						that.imgList.push({
							filePath: item.url,
							id: item.fId
						})
						that.oPhotoList1.push(item.url)
						that.previewImg.push(item.url)
					})

					// 视频
					var video = res.data.fSourcefileList
					video.map((item) => {
						var imgSrc = item.fFilePath
						var src;

						if (imgSrc.indexOf("mp4") != -1 && imgSrc.indexOf("C:") != -
							1) {
							imgSrc = imgSrc.replace(/D:/, "http://183.201.231.29:8389/")
							src = imgSrc.replace(/mp4/, "jpg")
						} else {
							src =
								"https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E8%A7%86%E9%A2%91%E5%9B%BE%E7%89%87&step_word=&hs=0&pn=43&spn=0&di=119790&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&istype=2&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=-1&cs=3346960024%2C2036034045&os=4174661132%2C668644710&simid=0%2C0&adpicid=0&lpn=0&ln=1485&fr=&fmq=1626946136579_R&fm=result&ic=&s=undefined&hd=&latest=&copyright=&se=&sme=&tab=0&width=&height=&face=undefined&ist=&jit=&cg=&bdtype=0&oriquery=&objurl=https%3A%2F%2Fgimg2.baidu.com%2Fimage_search%2Fsrc%3Dhttp%3A%2F%2Fpic.vjshi.com%2F2017-02-23%2F812ed99eb35888901ff0e220bb05120c%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark%26refer%3Dhttp%3A%2F%2Fpic.vjshi.com%26app%3D2002%26size%3Df9999%2C10000%26q%3Da80%26n%3D0%26g%3D0n%26fmt%3Djpeg%3Fsec%3D1629538162%26t%3Df3acdf9335d81ccd4fbc9cdc305d8dc3&fromurl=ippr_z2C%24qAzdH3FAzdH3Fooo_z%26e3Be3fit_z%26e3Bv54AzdH3FowpviAzdH3Fl00cam_z%26e3Bip4s&gsm=&rpstart=0&rpnum=0&islist=&querylist=&nojc=undefined"
						}
						that.fastImgLists.push({
							filePath: item.url,
							id: item.fId,
							src: src,
							needload: false,
							type: 'video'
						})

					})
					if (that.fromMsg.fSampletestpiece != "" && that.fromMsg.fSampletestpiece != null) {
						that.APPlist = that.fromMsg.fSampletestpiece.split(',')
					} else {
						that.APPlist = []
					}
					// if (that.fromMsg.fSampletypename == '硬化后水泥混凝土') {
					// 	this.fromMsg.fSamplemessage = "表面平整，无蜂窝麻面，无缺损"
					// } else {
					// 	this.fromMsg.fSamplemessage = ""
					// }
					// 表单展示
					if (that.fromMsg.fChecktypenum == "1") {
						that.Checktypenum = 1;
					} else if (that.fromMsg.fChecktypenum == "0") {
						that.Checktypenum = 0;
						that.isScanCode = false;
						if (that.fromMsg.fSampletypename == "土") {
							that.formObjText_zj = 1;
						} else if (that.fromMsg.fSampletypename == "粗集料" || that.fromMsg.fSampletypename ==
							"细集料" || that.fromMsg.fSampletypename ==
							"岩石") {
							that.formObjText_zj = 2;
							if (that.fromMsg.fSampletypename == "粗集料") {
								that.getDictionaryCode("Speci1");
							} else if (that.fromMsg.fSampletypename == "细集料") {
								that.getDictionaryCode("Speci2");
							} else if (that.fromMsg.fSampletypename == "岩石") {
								that.getDictionaryCode("Speci3");
							}
						} else if (that.fromMsg.fSampletypename == "矿粉") {
							that.formObjText_zj = 3;
						} else if (that.fromMsg.fSampletypename == "水泥") {
							that.formObjText_zj = 4;
							that.fStrengthgradeText = "品种强度等级";
							that.fSamplenoText = "出厂编号";
						} else if (that.fromMsg.fSampletypename == "水") {
							that.formObjText_zj = 5;
						} else if (that.fromMsg.fSampletypename == "外加剂") {
							that.formObjText_zj = 6;
							that.fProductiondatesText = "生产日期";
							that.fSamplenoText = "生产批号";
						} else if (that.fromMsg.fSampletypename == "石灰") {
							that.formObjText_zj = 7;
							that.fStrengthgradeText = "品种等级";
							that.fProductiondatesText = "生产日期";
							that.getDictionaryCode("Variety1");
						} else if (that.fromMsg.fSampletypename == "粉煤灰") {
							that.formObjText_zj = 8;
							that.fStrengthgradeText = "品种等级";
							that.fProductiondatesText = "生产日期";
						} else if (that.fromMsg.fSampletypename == "普通沥青") {
							that.formObjText_zj = 9;
							that.fTesttypeText = "沥青种类";
							that.fProductiondatesText = "生产日期";
							that.getDictionaryCode("Grade1");
						} else if (that.fromMsg.fSampletypename == "钢筋原材" || that.fromMsg.fSampletypename ==
							"钢筋焊接" || that.fromMsg.fSampletypename == "钢筋机械连接") {
							that.formObjText_zj = 10;
							that.isScanCode = true;
							that.fSamplenoText = "批号"
							that.fTesttypeText = "钢筋种类";
							that.getDictionaryCode("Diameter");
							that.getDictionaryCode("Brand");
						} else if (that.fromMsg.fSampletypename == "钢筋原材" || that.fromMsg.fSampletypename ==
							"钢筋机械连接" || that.fromMsg.fSampletypename ==
							"水泥混凝土抗弯拉" || that.fromMsg.fSampletypename == "水泥抗折抗压强度") {
							that.isScanCode = true;

						} else if (that.fromMsg.fSampletypename == "水泥混凝土拌合物") {
							that.formObjText_zj = 11;
							that.fStrengthgradeText = "强度等级";
							that.fTesttypeText = "混凝土种类";
							that.getDictionaryCode("StrengthGrade1");
							that.getDictionaryCode("Hnttype1");
							that.getDictionaryCode("StirringMethod1");
						} else if (that.fromMsg.fSampletypename == "硬化后水泥混凝土") {
							that.formObjText_zj = 12;
							that.isScanCode = true;
							that.fStrengthgradeText = "强度等级";
							that.fTesttypeText = "混凝土种类";
							that.fProductiondatesText = "制件日期";
							that.getDictionaryCode("StrengthGrade1");
							that.getDictionaryCode("Hnttype1");
							that.getDictionaryCode("StirringMethod1");
							that.getDictionaryCode("CuringCondition");
							that.getDictionaryCode("SpecimenAge1");
							that.getDictionaryCode("SpecimenSize1");

						} else if (that.fromMsg.fSampletypename == "水泥砂浆拌合物") {
							that.formObjText_zj = 13;
							that.fStrengthgradeText = "强度等级";
							that.fTesttypeText = "砂浆种类";
							that.getDictionaryCode("StirringMethod1");
						} else if (that.fromMsg.fSampletypename == "硬化后水泥砂浆") {
							that.formObjText_zj = 14;
							that.isScanCode = true;
							that.fStrengthgradeText = "强度等级";
							that.fTesttypeText = "砂浆种类";
							that.fProductiondatesText = "制件日期";
							that.getDictionaryCode("StrengthGrade3");
							that.getDictionaryCode("StirringMethod1");
							that.getDictionaryCode("CuringCondition");
							that.getDictionaryCode("SpecimenAge3");
							that.getDictionaryCode("SpecimenSize3");
						} else if (that.fromMsg.fSampletypename == "硬化后水泥净浆") {
							that.isScanCode = true;
							that.formObjText_zj = 15;
							that.getDictionaryCode("StirringMethod1");
							that.getDictionaryCode("StirringMethod1");

							that.getDictionaryCode("StrengthGrade4");
							that.getDictionaryCode("CuringCondition");
						} else if (that.fromMsg.fSampletypename == "沥青混合料") {
							that.formObjText_zj = 16;
							that.fTesttypeText = "沥青混合料类型";
						} else {
							that.formObjText_zj = 0;
						}
					}
					// 表单展示
					this.getfSampletypeFun();

				} else {
					uni.showToast({
						title: "获取详情数据失败",
						icon: 'none',
						duration: 2000
					});
				}
			}, (err) => {
				uni.showToast({
					title: "获取详情数据失败",
					icon: 'none',
					duration: 2000
				});
			});
		},


		// 弹框树结构--样品种类
		getfSampletypeFun() {
			var data = {
				fChecktypenum: this.Checktypenum, //0自检1外委
				fMaterialtypeid: this.fromMsg.fMaterialtypeid, //材料进场材料种类id
			};
			this.$http.getfSampletype(data)
				.then((res) => {
					if (res.errcode == 0) {
						this.treeData = this.tranListToTreeData(
							res.data.SampletypeList
						);
						this.companyTree = this.treeData; //机构树
					} else {
						uni.showToast({
							title: "获取样品种类失败",
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				})
		},
		tranListToTreeData(data) {
			let result = [];
			if (!Array.isArray(data)) {
				return result;
			}
			// 清除已存在的数据  重新赋值
			data.forEach((item) => {
				delete item.children;
			});

			let map = {};
			data.forEach((item) => {
				map[item.fSampletype] = item;
			});

			data.forEach((item) => {
				let parent = map[item.fParentId];
				if (parent) {
					(parent.children || (parent.children = [])).push(item);
				} else {
					result.push(item);
				}
			});
			return result;
		},
		treeConfirm(e, num) { //确认按钮
			console.log(e, num)

			this.fSampletypeindex = 0;
			var data = e[0];

			if (data.fSampletypename == '硬化后水泥混凝土') {
				this.fromMsg.fSamplemessage = "表面平整，无蜂窝麻面，无缺损"
			} else {
				this.fromMsg.fSamplemessage = ""
			}


			if (this.Checktypenum == "0") {
				this.isScanCode = false; //试件编号
				if (this.fromMsg.fSampletypename == data.fSampletypename) {
					// console.log(12);
				} else {

					this.APPlist = [];


					this.fromMsg.fAddress = ""; //取样地点
					this.fromMsg.fDeputynum = ""; //代表数量
					this.fromMsg.fSamplespecs = ""; //规格型号
					this.fromMsg.fPlace = ""; //产地
					this.fromMsg.fSampleno = ""; //生产批号  沥青标号  出厂编号
					this.fromMsg.fManufacturer = ""; //生产厂家
					this.fromMsg.fProductiondate = ""; //制件日期  生产日期
					this.fromMsg.fSamplenum = ""; //外加剂掺量
					this.fromMsg.fStrengthgrade = ""; //品种等级 品种强度等级 强度等级
					this.fromMsg.fDiameter = ""; //钢筋直径
					this.fromMsg.fSpecimenage = ""; //养护龄期
					// this.fromMsg.SpecimenageList = []; //养护龄期
					this.fromMsg.fSpecimensize = ""; //试件尺寸
					this.fromMsg.fSampletestpiece = ""; //试件编号
					this.fromMsg.fTesttype = ""; //沥青种类  钢筋种类 混凝土种类  砂浆种类 钢筋种类
					this.fromMsg.fMixingmethod = ""; //搅拌方式
					this.fromMsg.fWarecondition = ""; //养护条件
					this.fromMsg.fTestlayer = ""; //试验层位
					this.fromMsg.fGradationtype = ""; //级配类型
				}
				if (data.fSampletypename == "土") {
					this.formObjText_zj = 1;
				} else if (data.fSampletypename == "粗集料" || data.fSampletypename == "细集料" || data.fSampletypename ==
					"岩石") {
					this.formObjText_zj = 2;
					if (data.fSampletypename == "粗集料") {
						this.getDictionaryCode("Speci1");
					} else if (data.fSampletypename == "细集料") {
						this.getDictionaryCode("Speci2");
					} else if (data.fSampletypename == "岩石") {
						this.getDictionaryCode("Speci3");
					}
				} else if (data.fSampletypename == "矿粉") {
					this.formObjText_zj = 3;
				} else if (data.fSampletypename == "水泥") {
					this.formObjText_zj = 4;
					this.fStrengthgradeText = "品种强度等级";
					this.fSamplenoText = "出厂编号";
				} else if (data.fSampletypename == "水") {
					this.formObjText_zj = 5;
				} else if (data.fSampletypename == "外加剂") {
					this.formObjText_zj = 6;
					this.fProductiondatesText = "生产日期";
					this.fSamplenoText = "生产批号";
				} else if (data.fSampletypename == "石灰") {
					this.formObjText_zj = 7;
					this.fStrengthgradeText = "品种等级";
					this.fProductiondatesText = "生产日期";
					this.getDictionaryCode("Variety1");
				} else if (data.fSampletypename == "粉煤灰") {
					this.formObjText_zj = 8;
					this.fStrengthgradeText = "品种等级";
					this.fProductiondatesText = "生产日期";
				} else if (data.fSampletypename == "普通沥青") {
					this.formObjText_zj = 9;
					this.fTesttypeText = "沥青种类";
					this.fProductiondatesText = "生产日期";
					this.getDictionaryCode("Grade1");
				} else if (data.fSampletypename == "钢筋原材" || data.fSampletypename == "钢筋焊接" || data.fSampletypename ==
					"钢筋机械连接") {
					this.formObjText_zj = 10;
					this.fSamplenoText = "批号";
					this.fTesttypeText = "钢筋种类";
					this.getDictionaryCode("Diameter");
					this.getDictionaryCode("Brand");
					this.isScanCode = true;
				} else if (data.fSampletypename == "钢筋原材" || data.fSampletypename == "钢筋机械连接" || data.fSampletypename ==
					"水泥混凝土抗弯拉" || data.fSampletypename == "水泥抗折抗压强度") {
					this.isScanCode = true;

				} else if (data.fSampletypename == "水泥混凝土拌合物") {
					this.formObjText_zj = 11;
					this.fStrengthgradeText = "强度等级";
					this.fTesttypeText = "混凝土种类";
					this.getDictionaryCode("StrengthGrade1");
					this.getDictionaryCode("Hnttype1");
					this.getDictionaryCode("StirringMethod1");
				} else if (data.fSampletypename == "硬化后水泥混凝土") {
					this.formObjText_zj = 12;
					this.isScanCode = true;
					this.fStrengthgradeText = "强度等级";
					this.fTesttypeText = "混凝土种类";
					this.fProductiondatesText = "制件日期";
					this.getDictionaryCode("StrengthGrade1");
					this.getDictionaryCode("Hnttype1");
					this.getDictionaryCode("StirringMethod1");
					this.getDictionaryCode("CuringCondition");
					this.getDictionaryCode("SpecimenAge1");
					this.getDictionaryCode("SpecimenSize1");

				} else if (data.fSampletypename == "水泥砂浆拌合物") {
					this.formObjText_zj = 13;
					this.fStrengthgradeText = "强度等级";
					this.fTesttypeText = "砂浆种类";
					this.getDictionaryCode("StirringMethod1");
				} else if (data.fSampletypename == "硬化后水泥砂浆") {
					this.formObjText_zj = 14;
					this.isScanCode = true;
					this.fStrengthgradeText = "强度等级";
					this.fTesttypeText = "砂浆种类";
					this.fProductiondatesText = "制件日期";
					this.getDictionaryCode("StrengthGrade3");
					this.getDictionaryCode("StirringMethod1");
					this.getDictionaryCode("CuringCondition");
					this.getDictionaryCode("SpecimenAge3");
					this.getDictionaryCode("SpecimenSize3");
				} else if (data.fSampletypename == "硬化后水泥净浆") {
					this.formObjText_zj = 15;
					this.isScanCode = true;
					this.getDictionaryCode("StirringMethod1");
					this.getDictionaryCode("StrengthGrade4");
					this.getDictionaryCode("CuringCondition");
				} else if (data.fSampletypename == "沥青混合料") {
					this.formObjText_zj = 16;
					this.fTesttypeText = "沥青混合料类型";
				} else {
					this.formObjText_zj = 0;
				}
			} else if (this.Checktypenum == "1") {
				console.log("this.Checktypenum", this.Checktypenum);
				this.fSamplespecs = false;
				if (data.fSampletypename == "粗集料") {
					this.getDictionaryCode("Speci1");
				} else if (data.fSampletypename == "细集料") {
					this.getDictionaryCode("Speci2");
				} else if (data.fSampletypename == "钢筋原材" || data.fSampletypename == "钢筋焊接" || data.fSampletypename ==
					"钢筋机械连接") {
					this.getDictionaryCode("Brand");
				} else {
					this.fSamplespecs = true;
				}
			}
			this.showdialog = false;
			this.fromMsg.fSampletype = data.fSampletype; //样品种类id 隐藏
			this.fromMsg.fSampletypename = data.fSampletypename; //样品种类汉字
			this.fromMsg.fSamplemodel = data.fSamplemodel; //样品编码
			this.fromMsg.fVarietyid = data.fVarietyid; //调厂家用id
			this.getPurveyorData(data.fVarietyid); //生产厂家下拉框list
		},
		treeCancel() { //取消按钮
			this.showdialog = false
		},
		// 弹框树结构--样品种类


		// 下拉框/弹框/扫描---选择
		ChecktypenumChange(e) { //取样类型
			console.log("取样类型", e);
			this.fromMsg.fChecktypenum = e.value;
			this.fromMsg.fChecktype = e.label;
			this.Checktypenum = e.value;
			// 赋值清空
			this.fromMsg.fAddress = ""; //取样地点
			this.fromMsg.fDeputynum = ""; //代表数量
			this.fromMsg.fSamplespecs = ""; //规格型号
			this.fromMsg.fPlace = ""; //产地
			this.fromMsg.fSampleno = ""; //生产批号  沥青标号  出厂编号
			this.fromMsg.fManufacturer = ""; //生产厂家
			this.fromMsg.fProductiondate = ""; //制件日期  生产日期
			this.fromMsg.fSamplenum = ""; //外加剂掺量
			this.fromMsg.fStrengthgrade = ""; //品种等级 品种强度等级 强度等级
			this.fromMsg.fDiameter = ""; //钢筋直径
			this.fromMsg.fSpecimenage = ""; //养护龄期
			// this.fromMsg.SpecimenageList = []; //养护龄期
			this.fromMsg.fSpecimensize = ""; //试件尺寸
			this.fromMsg.fSampletestpiece = ""; //试件编号
			this.fromMsg.fTesttype = ""; //沥青种类  钢筋种类 混凝土种类  砂浆种类 钢筋种类
			this.fromMsg.fMixingmethod = ""; //搅拌方式
			this.fromMsg.fWarecondition = ""; //养护条件
			this.fromMsg.fTestlayer = ""; //试验层位
			this.fromMsg.fGradationtype = ""; //级配类型
			this.fromMsg.fSampletype = ""; //样品种类id 隐藏
			this.fromMsg.fSampletypename = ""; //样品种类汉字
			this.fromMsg.fSamplemodel = ""; //样品编码

			this.fromMsg.fEntryledgerid = ""; //材料进场编号id 隐藏
			this.fromMsg.fEntrynumber = ""; //材料进场编号
			this.fromMsg.fMaterialtypeid = ""; //材料进场材料种类id
			this.fromMsg.fBusinessscopename = ""; //取样标段
			this.fromMsg.fApproachdates = ""; //进场日期
			// 赋值清空
			this.getfSampletypeFun();
		},
		EntrynumberFocus() { // 材料进场编号
			if (this.Checktypenum == "0" && this.userInfo.companyNature == "施工单位") {
				uni.showToast({
					title: '该用户不可编辑"材料进场编号"',
					icon: 'none',
					duration: 2000
				});
			} else {
				console.log('this.fromMsg', this.fromMsg);
				uni.navigateTo({
					url: "/pages/apply/sampleManage/fieldSampling/listPage?fId=" +
						this.fromMsg.fId + "&selectId=" + this.fromMsg.fEntryledgerid
				});
			}
			return false;
		},
		SampletypenameFocus() { //样品种类
			this.showdialog = true
			this.$refs.company._show();
		},
		TesttypeChange(e) { // 试件类型下拉选择
			console.log("试件类型下拉选择", e);
		},
		BusinessscopenameChange(e) { //取样标段
			console.log('6666666666666666', e);
			if (e == "==请选择==") {
				this.fromMsg.fBusinessscopename = ""; //取样标段
			}
		},
		selectChange(e) { //巡查项目部
			console.log('22222222222', e);
			if (this.userInfo.companyNature != '施工单位') {
				this.fromMsg.fBusinessscopename = e.label; //取样标段
				this.fromMsg.fBusinessscopecompanyid = e.value;
			}
		},
		StrengthgradeChange(e) { // 强度等级下拉选择
			if (e == "==请选择==") {
				this.fromMsg.fStrengthgrade = ""; //强度等级
			}
		},
		// 龄期
		SpecimenageChange(e) { // 试件龄期下拉选择
			var list = e.detail.data;
			var a = [];
			list.map((item, index) => {
				a.push(item.fItemname);
			});
			this.fromMsg.fSpecimenage = a.join(",");
		},
		confirm(data) {

			this.fromMsg.fSpecimenage = data.map(el => el.fItemName).join(",");
			this.fSpecimenageindex = 0
		},
		// 试件尺寸
		SpecimensizeChange(e) { // 试件尺寸下拉选择
			if (e == "==请选择==") {
				this.fromMsg.fSpecimensize = ""; //试件尺寸
			}
		},
		fStrengthgradeChange(e) { // 试件尺寸下拉选择
			if (e == "==请选择==") {
				this.fromMsg.fStrengthgrade = ""; //试件尺寸
			}
		},
		fTesttypeChange(e) { // 试件尺寸下拉选择
			if (e == "==请选择==") {
				this.fromMsg.fTesttype = ""; //试件尺寸
			}
		},
		fMixingmethodChange(e) { // 试件尺寸下拉选择
			if (e == "==请选择==") {
				this.fromMsg.fMixingmethod = ""; //试件尺寸
			}
		},
		BrandChange(e) { // 牌号下拉选择
			if (e == "==请选择==") {
				this.fromMsg.fBrand = ""; //牌号
				this.fromMsg.fDiameter = ""; //直径
			}
		},
		DiameterChange(e) { // 直径下拉选择
			if (e == "==请选择==") {
				this.fromMsg.fDiameter = ""; //直径
			}
		},
		SampletestpieceChange(e) { // 事件编码扫描
		},
		ManufacturerChange(e) { //生产厂家下拉选择
			this.fromMsg.fStrengthlevel = e;
		},
		// 下拉框/弹框/扫描---选择

		// 保存/提交
		clickNum(data) {
			this.resultFrom(data);
		},
		resultFrom(data) {
			this.fromMsg.isSubmit = data;
			// console.log(data,data.fSampletypename);
			if (this.Checktypenum == '0') {
				if (this.fromMsg.fChecktypenum == "" || this.fromMsg.fChecktypenum == undefined) {
					uni.showToast({
						title: '请输入取样类型',
						icon: 'none',
						duration: 2000
					});
					return false;
				} else if (this.fromMsg.fSamplenostr == "" || this.fromMsg.fSamplenostr == undefined) {
					uni.showToast({
						title: '请填写样品编号',
						icon: 'none',
						duration: 2000
					});
					return false;
				} else if (this.fromMsg.fSampletypename == "" || this.fromMsg.fSampletypename == undefined) {
					uni.showToast({
						title: '请选择样品种类',
						icon: 'none',
						duration: 2000
					});
					return false;
				} else if (this.fromMsg.fSamplename == "" || this.fromMsg.fSamplename == undefined) {
					uni.showToast({
						title: '请输入样品名称',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fBusinessscopename == "" || this.fromMsg.fBusinessscopename ==
					undefined) {
					uni.showToast({
						title: '请输入取样标段',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fSamplemessage == "" || this.fromMsg.fSamplemessage == undefined) {
					uni.showToast({
						title: '请输入样品描述',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fApproachdates == "" || this.fromMsg.fApproachdates == undefined) {
					uni.showToast({
						title: '请选择进场日期',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fSampledates == "" || this.fromMsg.fSampledates == undefined) {
					uni.showToast({
						title: '请选择取样日期',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.imgList.length == 0) {
					uni.showToast({
						title: '请上传取样现场照片',
						icon: 'none',
						duration: 2000
					});
					return false;
				};
				var that = this;
				if (this.fromMsg.fSampletypename == "土") {
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (this.fromMsg.fSampletypename == "粗集料" || this.fromMsg.fSampletypename == "细集料" || this
					.fromMsg.fSampletypename ==
					"岩石" || this.fromMsg.fSampletypename == "矿粉") {
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSamplespecs == "" || that.fromMsg.fSamplespecs == undefined) {
						uni.showToast({
							title: '请填写规格型号',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fPlace == "" || that.fromMsg.fPlace == undefined) {
						uni.showToast({
							title: '请填写产地',
							icon: 'none',
							duration: 2000
						});
						return false;
					}

				} else if (this.fromMsg.fSampletypename == "水泥") {
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fManufacturer == "" || that.fromMsg.fManufacturer == undefined) {
						uni.showToast({
							title: '请填写生产厂家',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fStrengthgrade == "" || that.fromMsg.fStrengthgrade == undefined) {
						uni.showToast({
							title: '请填写品种强度等级',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampleno == "" || that.fromMsg.fSampleno == undefined) {
						uni.showToast({
							title: '请填写出厂编号',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (this.fromMsg.fSampletypename == "外加剂") {
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fManufacturer == "" || that.fromMsg.fManufacturer == undefined) {
						uni.showToast({
							title: '请填写生产厂家',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSamplenum == "" || that.fromMsg.fSamplenum == undefined) {
						uni.showToast({
							title: '请填写外加剂掺量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampleno == "" || that.fromMsg.fSampleno == undefined) {
						uni.showToast({
							title: '请填写生产批号',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fProductiondates == "" || that.fromMsg.fProductiondates ==
						undefined) {
						uni.showToast({
							title: '请填写生产日期',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (this.fromMsg.fSampletypename == "石灰") {
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fManufacturer == "" || that.fromMsg.fManufacturer == undefined) {
						uni.showToast({
							title: '请填写生产厂家',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fStrengthgrade == "" || that.fromMsg.fStrengthgrade == undefined) {
						uni.showToast({
							title: '请填写品种等级',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fProductiondates == "" || that.fromMsg.fProductiondates ==
						undefined) {
						uni.showToast({
							title: '请填写生产日期',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (this.fromMsg.fSampletypename == "粉煤灰") {
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fManufacturer == "" || that.fromMsg.fManufacturer == undefined) {
						uni.showToast({
							title: '请填写生产厂家',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fStrengthgrade == "" || that.fromMsg.fStrengthgrade == undefined) {
						uni.showToast({
							title: '请填写品种等级',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fProductiondates == "" || that.fromMsg.fProductiondates ==
						undefined) {
						uni.showToast({
							title: '请填写生产日期',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (this.fromMsg.fSampletypename == "普通沥青") {
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fManufacturer == "" || that.fromMsg.fManufacturer == undefined) {
						uni.showToast({
							title: '请填写厂家(产地)',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampleno == "" || that.fromMsg.fSampleno == undefined) {
						uni.showToast({
							title: '请填写沥青标号',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fTesttype == "" || that.fromMsg.fTesttype == undefined) {
						uni.showToast({
							title: '请填写沥青种类',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fProductiondates == "" || that.fromMsg.fProductiondates ==
						undefined) {
						uni.showToast({
							title: '请填写生产日期',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (this.fromMsg.fSampletypename == "钢筋原材" || this.fromMsg.fSampletypename == "钢筋焊接" || this
					.fromMsg.fSampletypename ==
					"钢筋机械连接") {

					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fManufacturer == "" || that.fromMsg.fManufacturer == undefined) {
						uni.showToast({
							title: '请填写生产厂家',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampleno == "" || that.fromMsg.fSampleno == undefined) {
						uni.showToast({
							title: '请填写批号',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fDiameter == "" || that.fromMsg.fDiameter == undefined) {
						uni.showToast({
							title: '请填写钢筋直径',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fTesttype == "" || that.fromMsg.fTesttype == undefined) {
						uni.showToast({
							title: '请填写钢筋种类',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampletestpiece == "" || that.fromMsg.fSampletestpiece == undefined) {
						uni.showToast({
							title: '请填写试件编号',
							icon: 'none',
							duration: 2000
						});
						return false;
					}

				} else if (this.fromMsg.fSampletypename == "水泥混凝土拌合物") {
					if (that.fromMsg.fStrengthgrade == "" || that.fromMsg.fStrengthgrade == undefined) {
						uni.showToast({
							title: '请填写强度等级',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fTesttype == "" || that.fromMsg.fTesttype == undefined) {
						uni.showToast({
							title: '请填写混凝土种类',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fMixingmethod == "" || that.fromMsg.fMixingmethod == undefined) {
						uni.showToast({
							title: '请填写搅拌方式',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (this.fromMsg.fSampletypename == "硬化后水泥混凝土") {

					if (that.fromMsg.fStrengthgrade == "" || that.fromMsg.fStrengthgrade == undefined) {
						uni.showToast({
							title: '请填写强度等级',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fTesttype == "" || that.fromMsg.fTesttype == undefined) {
						uni.showToast({
							title: '请填写混凝土种类',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fMixingmethod == "" || that.fromMsg.fMixingmethod == undefined) {
						uni.showToast({
							title: '请填写搅拌方式',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fWarecondition == "" || that.fromMsg.fWarecondition == undefined) {
						uni.showToast({
							title: '请填写养护条件',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fProductiondates == "" || that.fromMsg.fProductiondates ==
						undefined) {
						uni.showToast({
							title: '请填写制件日期',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSpecimenage == "" || that.fromMsg.fSpecimenage == undefined) {
						uni.showToast({
							title: '请填写养护龄期',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSpecimensize == "" || that.fromMsg.fSpecimensize == undefined) {
						uni.showToast({
							title: '请填写试件尺寸',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampletestpiece == "" || that.fromMsg.fSampletestpiece == undefined) {
						uni.showToast({
							title: '请填写试件编号',
							icon: 'none',
							duration: 2000
						});
						return false;
					}

				} else if (this.fromMsg.fSampletypename == "水泥砂浆拌合物") {

					if (that.fromMsg.fStrengthgrade == "" || that.fromMsg.fStrengthgrade == undefined) {
						uni.showToast({
							title: '请填写强度等级',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fTesttype == "" || that.fromMsg.fTesttype == undefined) {
						uni.showToast({
							title: '请填写砂浆种类',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fMixingmethod == "" || that.fromMsg.fMixingmethod == undefined) {
						uni.showToast({
							title: '请填写搅拌方式',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (that.fromMsg.fSampletypename == "硬化后水泥砂浆") {

					if (that.fromMsg.fStrengthgrade == "" || that.fromMsg.fStrengthgrade == undefined) {
						uni.showToast({
							title: '请填写强度等级',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fTesttype == "" || that.fromMsg.fTesttype == undefined) {
						uni.showToast({
							title: '请填写砂浆种类',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fMixingmethod == "" || that.fromMsg.fMixingmethod == undefined) {
						uni.showToast({
							title: '请填写搅拌方式',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fWarecondition == "" || that.fromMsg.fWarecondition == undefined) {
						uni.showToast({
							title: '请填写养护条件',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fProductiondates == "" || that.fromMsg.fProductiondates ==
						undefined) {
						uni.showToast({
							title: '请填写制件日期',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSpecimenage == "" || that.fromMsg.fSpecimenage == undefined) {
						uni.showToast({
							title: '请填写养护龄期',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSpecimensize == "" || that.fromMsg.fSpecimensize == undefined) {
						uni.showToast({
							title: '请填写试件尺寸',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampletestpiece == "" || that.fromMsg.fSampletestpiece == undefined) {
						uni.showToast({
							title: '请填写试件编号',
							icon: 'none',
							duration: 2000
						});
						return false;
					}

				} else if (this.fromMsg.fSampletypename == "硬化后水泥净浆") {
					this.formObjText_zj = 15;
					if (that.fromMsg.fMixingmethod == "" || that.fromMsg.fMixingmethod == undefined) {
						uni.showToast({
							title: '请填写搅拌方式',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
					// if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
					// 	uni.showToast({
					// 		title: '请填写代表数量',
					// 		icon: 'none',
					// 		duration: 2000
					// 	});
					// 	return false;
					// } else 
					if (that.fromMsg.fWarecondition == "" || that.fromMsg.fWarecondition == undefined) {
						uni.showToast({
							title: '请填写养护条件',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				} else if (this.fromMsg.fSampletypename == "沥青混合料") {
					this.formObjText_zj = 16;
					this.fTesttypeText = "沥青混合料类型";
					if (that.fromMsg.fTesttype == "" || that.fromMsg.fTesttype == undefined) {
						uni.showToast({
							title: '请填写沥青混合料类型',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fTestlayer == "" || that.fromMsg.fTestlayer == undefined) {
						uni.showToast({
							title: '请填写试验层位',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fGradationtype == "" || that.fromMsg.fGradationtype == undefined) {
						uni.showToast({
							title: '请填写级配类型',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fProductiondates == "" || that.fromMsg.fProductiondates ==
						undefined) {
						uni.showToast({
							title: '请填写制件日期',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSpecimenage == "" || that.fromMsg.fSpecimenage == undefined) {
						uni.showToast({
							title: '请填写养护龄期',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSpecimensize == "" || that.fromMsg.fSpecimensize == undefined) {
						uni.showToast({
							title: '请填写试件尺寸',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampletestpiece == "" || that.fromMsg.fSampletestpiece == undefined) {
						uni.showToast({
							title: '请填写试件编号',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				}





			} else {



				if (this.fromMsg.fChecktypenum == "" || this.fromMsg.fChecktypenum == undefined) {
					uni.showToast({
						title: '请输入取样类型',
						icon: 'none',
						duration: 2000
					});
					return false;
				} else if (this.fromMsg.fSampletypename == "" || this.fromMsg.fSampletypename == undefined) {
					uni.showToast({
						title: '请选择样品种类',
						icon: 'none',
						duration: 2000
					});
					return false;
				} else if (this.fromMsg.fSamplename == "" || this.fromMsg.fSamplename ==
					undefined) {
					uni.showToast({
						title: '请输入样品名称',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fSamplespecs == "" || this.fromMsg.fSamplespecs == undefined) {
					uni.showToast({
						title: '请输入规格型号',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fBusinessscopename == "" || this.fromMsg.fBusinessscopename ==
					undefined) {
					uni.showToast({
						title: '请输入取样标段',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fSampleno == "" || this.fromMsg.fSampleno == undefined) {
					uni.showToast({
						title: '请输入批号/编号',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fSamplemessage == "" || this.fromMsg.fSamplemessage == undefined) {
					uni.showToast({
						title: '请输入样品描述',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fManufacturer == "" || this.fromMsg.fManufacturer == undefined) {
					uni.showToast({
						title: '请选择生产厂家',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fAddress == "" || this.fromMsg.fAddress == undefined) {
					uni.showToast({
						title: '请选择取样地点',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fSamplenum == "" || this.fromMsg.fSamplenum == undefined) {
					uni.showToast({
						title: '请输入取样数量',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fDeputynum == "" || this.fromMsg.fDeputynum == undefined) {
					uni.showToast({
						title: '请输入代表数量',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fApproachdates == "" || this.fromMsg.fApproachdates == undefined) {
					uni.showToast({
						title: '请选择进场日期',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.fromMsg.fSampledates == "" || this.fromMsg.fSampledates == undefined) {
					uni.showToast({
						title: '请选择取样日期',
						icon: 'none',
						duration: 2000
					});
					return false;

				} else if (this.imgList.length == 0) {
					uni.showToast({
						title: '请上传取样现场照片',
						icon: 'none',
						duration: 2000
					});
					return false;
				};


				if (
					this.fromMsg.fSampletypename == "钢筋原材" ||
					this.fromMsg.fSampletypename == "钢筋焊接" ||
					this.fromMsg.fSampletypename == "钢筋机械连接" ||
					this.fromMsg.fSampletypename == "硬化后水泥混凝土" ||
					this.fromMsg.fSampletypename == "硬化后水泥砂浆" ||
					this.fromMsg.fSampletypename == "硬化后水泥净浆" ||
					this.fromMsg.fSampletypename == "水泥混凝土抗弯拉" ||
					this.fromMsg.fSampletypename == "水泥抗折抗压强度"
				) {
					var that = this;
					if (that.fromMsg.fDeputynum == "" || that.fromMsg.fDeputynum == undefined) {
						uni.showToast({
							title: '请填写代表数量',
							icon: 'none',
							duration: 2000
						});
						return false;
					} else if (that.fromMsg.fSampletestpiece == "" || that.fromMsg.fSampletestpiece == undefined) {
						uni.showToast({
							title: '请填写试件编号',
							icon: 'none',
							duration: 2000
						});
						return false;
					}
				}
			}


			if (this.isLock == true) {
				this.fromMsg.fNature = this.userInfo.companyNature;
				this.$http.saveSampleWork(this.fromMsg).then(res => {
					if (res.errcode == 0) {
						this.isLock = false;
						this.$refs.loadings.open();
						this.routerPush(data)
					} else {
						this.isLock = true;
						this.$refs.loadings.close();
						this.clickN = 0
					}
				})
			}
			this.isLock = false;
		},
		routerPush(data) {
			setTimeout(() => {

				if (data == '0') {
					uni.showToast({
						title: "保存成功",
						icon: 'none',
						duration: 2000
					});
				} else {
					uni.showToast({
						title: "提交成功",
						icon: 'none',
						duration: 2000

					});
				}
				let that = this;
				that.isLock = false;
				uni.redirectTo({
					url: "/pages/apply/sampleManage/fieldSampling/testing/index?Inv=" +
						data,
					success: () => {
						// that.clickN = 1;
						that.click = false;
						that.$refs.loadings.close();
					}
				})
			}, 1500)
		},
		// 保存/提交


		// 原生窗体按钮显示
		playVideo() {
			let subNVue = uni.getSubNVueById('fieldSampling')
			subNVue.show()
		},
		// 获取当前日期
		getDate() {
			var time = new Date();
			const y = time.getFullYear();
			const m = (time.getMonth() + 1 + "").padStart(2, "0");
			const d = (time.getDate() + "").padStart(2, "0");
			const hh = (time.getHours() + "").padStart(2, "0");
			const mm = (time.getMinutes() + "").padStart(2, "0");
			const ss = (time.getSeconds() + "").padStart(2, "0");
			var timer = `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
			var timing = `${y}-${m}-${d}`;
			// this.fromMsg.fNoticedates = timing;
			// this.fromMsg.fFillingdates = timing;
		},
		//生产厂家List
		getPurveyorData(id) {
			var data = {
				page: 1,
				pageSize: 500,
				merchantName: "", //生产厂家
				fVarietyid: id, //种类ID
				typ: "1" //"1"材料生产商，"2"材料供应商
			}
			this.$http.getPurveyorDataList(data).then(res => {
				if (res.errcode == 0) {
					this.ManufacturerList = [];
					res.data.pageInfo.list.map(item => {
						this.ManufacturerList.push(item.fMerchantname);
					})
				} else {
					uni.showToast({
						title: "生产厂家获取数据失败",
						icon: 'none',
						duration: 2000
					});
				}
			}, (err) => {
				uni.showToast({
					title: "生产厂家接口报错",
					icon: 'none',
					duration: 2000
				});
			});
		},
		//取样标段List
		getTree() {
			var data = {
				companyId: this.userInfo.companyId,
				userId: this.userInfo.userId,
				// text: "4", // 0其他  1 砼拌合站 2水稳 3沥青 4张拉压浆
			};

			this.$http.getUserCompanyTreeList(data).then(res => {
				if (res.errcode == 0) {
					var BusinessscopenameMap = [];
					res.data.userCompanyTreeList.map(item => {
						if (item.fCompanyid != this.userInfo.companyId) {
							BusinessscopenameMap.push({
								label: item.fShortname,
								value: item.fCompanyid,
							})
						}
					});
					this.BusinessscopenameList = BusinessscopenameMap;
					// var companyTree = this.treeListToTreeData(res.data.userCompanyTreeList);
					// this.BusinessscopenameList = [{
					// 	label: "==请选择==",
					// 	value: ""
					// }, {
					// 	label: companyTree[0].fShortname,
					// 	value: companyTree[0].fCompanyid
					// }];
					// // console.log('ppppp', companyTree,88,this.BusinessscopenameList);

					// if (companyTree[0].children) {
					// 	companyTree[0].children.map((item) => {
					// 		this.BusinessscopenameList.push({
					// 			label: item.fShortname,
					// 			value: item.fCompanyid
					// 		});
					// 	});
					// }
				} else {
					uni.showToast({
						title: "取样标段获取数据失败",
						icon: 'none',
						duration: 2000
					});
				}
			}, (err) => {
				uni.showToast({
					title: "取样标段接口报错",
					icon: 'none',
					duration: 2000
				});
			});
		},

		treeListToTreeData(data) {
			//处理树状图数据
			let result = [];
			if (!Array.isArray(data)) {
				return result;
			}
			// 清除已存在的children 重新赋值
			data.forEach((item) => {
				delete item.children;
			});

			let map = {};
			data.forEach((item) => {
				map[item.fCompanyid] = item;
			});

			data.forEach((item) => {
				let parent = map[item.fParentid];
				if (parent) {
					(parent.children || (parent.children = [])).push(item);
				} else {
					result.push(item);
				}
			});
			return result;
		},



		// 字典项
		getDictionaryCode(data) { //字典项
			this.$http.getBaseDataitemDetailByItemCode({
				fItemcode: data
			}).then(res => {
				if (res.errcode == 0) {
					var dataMpu = ["==请选择=="];
					res.data.baseDataitemdetailList.map(item => {
						dataMpu.push(item.fItemname);
					})
					if (data == "Speci1" || data == "Speci2" || data == "Speci3") {
						// 规格型号
						this.fSamplespecsList = dataMpu;
						if (this.Checktypenum == "1") {
							this.fSamplespecsList = dataMpu;
						}
					} else if (data == "Variety1" || data == "StrengthGrade1" || data ==
						"StrengthGrade3" || data ==
						"StrengthGrade4") {
						//品种等级、强度等级
						this.fStrengthgradeList = dataMpu;
					} else if (data == "Grade1") {
						//沥青标号
						this.fSamplenoList = dataMpu;
					} else if (data == "Diameter") {
						//钢筋直径
						this.fDiameterList = dataMpu;
					} else if (data == "Brand" || data == "Hnttype1") {
						// 钢筋种类、混凝土种类
						this.fTesttypeList = dataMpu;

						if (this.Checktypenum == "1" && data == "Brand") {
							// 外委规格型号
							this.fSamplespecsList = dataMpu;
						}
					} else if (data == "SpecimenAge1" || data == "SpecimenAge3") {
						// 养护龄期
						this.fSpecimenageList = dataMpu;
					} else if (data == "SpecimenSize1" || data == "SpecimenSize3") {
						//试件尺寸
						this.fSpecimensizeList = dataMpu;
					} else if (data == "StirringMethod1") {
						//搅拌方式
						this.fMixingmethodList = dataMpu;
					} else if (data == "CuringCondition") {
						//养护条件
						this.fWareconditionList = dataMpu;
					}
				} else {
					uni.showToast({
						title: "字典项获取数据失败",
						icon: 'none',
						duration: 2000
					});
				}
			}, (err) => {
				uni.showToast({
					title: "字典项接口报错",
					icon: 'none',
					duration: 2000
				});
			});
		},
		// 字典项


		// 定位
		getaaa() {
			var that = this;
			var url = encodeURIComponent(window.location.href.split("#")[0]);
			this.$http.checkToken({
				url: url
			}).then(res => {
				let data = res.data;
				wx.config({
					debug: false,
					appId: data.appId,
					timestamp: data.timestamp,
					nonceStr: data.nonceStr,
					signature: data.signature,
					jsApiList: ["checkJsApi", "openLocation"],
					success(res) {
						console.log('定位', res)
					}
				})
				wx.ready(function() {
					wx.getLocation({
						type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
						success: function(res) {
							var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
							var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
							that.latitude = latitude;
							that.longitude = longitude;
							that.getMakers()
							that.page = true
						}
					})
				})


			})
		},
		// marker 标记点
		getMakers() {
			if (this.latitude != "" && this.longitude != "") {
				var markers = []
				var that = this
				markers = markers.concat({
					iconPath: this.iconpath,
					latitude: that.latitude, //纬度
					longitude: that.longitude, //经度

					callout: { //自定义标记点上方的气泡窗口 点击有效
						content: '当前位置', //文本
						color: '#ffffff', //文字颜色
						fontSize: 10, //文本大小
						borderRadius: 2, //边框圆角
						bgColor: '#00c16f', //背景颜色
						display: 'ALWAYS', //常显
					},
				})
				that.markers = markers
			}
		},
		//定位


		// 照片/视频
		// 视频详情
		interVideo(src) {
			uni.navigateTo({
				url: '/pages/apply/commonVideo/commonVideo?src=' + src
			});
		},
		aaaa() {
			var aa =
				"http://129.28.66.56:8301//fileAnnexes/afab4d2b-04a3-40f9-87f0-46bb8602c44b/20200907/wu_1ehj2mtm2guuddc17uuhgmhpo7.pdf"
			let links = encodeURIComponent(aa)
			uni.navigateTo({
				url: '/pages/pdf/pdf?links=' + links,
			})

		},
		sourceTypeChange() {
			var that = this
			uni.showActionSheet({
				title: '选择类型',
				itemList: that.sourceType,
				success: e => {
					this.sourceTypeIndex = e.tapIndex
					that.ChooseImage(this.sourceTypeIndex)
				}
			});

		},
		// 控制视频折叠面板
		changeContent() {
			this.contentShow = !this.contentShow
		},
		// 相机权限
		async checkPermission(code) {
			let type = code ? code - 1 : this.sourceTypeIndex;
			let status = permision.isIOS ? await permision.requestIOS(sourceType[type][0]) :
				await permision.requestAndroid(type === 0 ? 'android.permission.CAMERA' :
					'android.permission.READ_EXTERNAL_STORAGE');

			if (status === null || status === 1) {
				status = 1;
			} else {
				uni.showModal({
					content: "没有开启权限",
					confirmText: "设置",
					success: function(res) {
						if (res.confirm) {
							permision.gotoAppSetting();
						}
					}
				})
			}

			return status;
		},
		compress(img) {
			let that = this
			return new Promise((res) => {
				// var localPath = plus.io.convertAbsoluteFileSystem(img);
				plus.io.resolveLocalFileSystemURL(img, (entry) => { //通过URL参数获取目录对象或文件对象
					entry.file((file) => { // 可通过entry对象操作图片 
						if (file.size > 504800) { //   如果大于500Kb进行压缩
							plus.zip.compressImage({ // 5+ plus.zip.compressImage 了解一下，有详细的示例
								src: img, //src: 压缩原始图片的路径    
								dst: img.replace('.png', '2222.png')
									.replace('.PNG',
										'2222.PNG').replace('.jpg',
										'2222.jpg')
									.replace('.JPG', '2222.JPG'),
								width: '40%', //dst: (String 类型 )压缩转换目标图片的路径，这里先在后面原始名后面加一个2222区分一下
								height: '40%', //width,height: (String 类型 )缩放图片的宽度,高度
								quality: 10, //quality: (Number 类型 )压缩图片的质量
								overwrite: true, //overwrite: (Boolean 类型 )覆盖生成新文件
								// format:'jpg'   //format: (String 类型 )压缩转换后的图片格式
							}, (event) => {
								// 	event)); // 压缩后图片信息
								this.imageInfo = event
								let newImg = event.target;
								res(newImg); //返回新的图片地址，在uploadFile之前接收
							}, function(err) {});
						} else { //else小于500kb跳过压缩，直接返回现有的src
							res(img);
						}
					});
				}, (e) => { // 返回错误信息
				});
			})
		},
		async uploadFile(image) {
			var that = this
			uni.showLoading({
				mask: true,
				title: '上传中...'
			})
			// #ifdef APP-PLUS
			this.imageA = await this.compress(image); // await--上传图片之前先压缩，否则上传会比压缩先执行
			// #endif
			// #ifdef H5
			this.imageA = image
			// #endif
			//开始上传，此处可先注释看压缩效果
			uni.uploadFile({
				url: this.$http.upload,
				method: "POST",
				formData: {
					folderid: that.fromMsg.fPhotofile,
					userId: that.userInfo.userId, // 当前登录用户的 id
					userName: that.userInfo.realName,
				},
				// filePath: imgSrc,
				filePath: that.imageA,
				name: 'file',
				success(res) {
					uni.hideLoading()
					let imgitem = {};

					imgitem.id = JSON.parse(res.data)[0].atta.fId
					var imgArr = JSON.parse(res.data)[0].atta.fFilepath
					// 	imgArr = imgArr.replace(/D:/, this.$http.file)
					// 	that.oPhotoList.push(imgArr)
					// }
					imgitem.filePath = that.imageA;
					that.previewImg.push(that.imageA)
					that.imgList.push(imgitem);
				},
				fail(res) {}
			})
		},
		// 选择照片
		async ChooseImage(e) {
			var that = this
			// #ifdef APP-PLUS
			// TODO 选择相机或相册时 需要弹出actionsheet，目前无法获得是相机还是相册，在失败回调中处理
			if (this.sourceTypeIndex !== 2) {
				let status = await this.checkPermission();
				if (status !== 1) {
					return;
				}
			}
			// #endif

			uni.chooseImage({
				count: 1, //默认9
				sourceType: sourceType[e],
				sizeType: ['original', 'compressed'],
				success: (res) => {
					var imgSrc = res.tempFilePaths[0]
					var imageSrc = res.tempFilePaths
					that.uploadFile(res.tempFilePaths[0])
				},
				fail(err) {
					// #ifdef APP-PLUS
					if (err['code'] && err.code !== 0 && this.sourceTypeIndex === 2) {
						this.checkPermission(err.code);
					}
					// #endif
					// #ifdef MP
					if (err.errMsg.indexOf('cancel') !== '-1') {
						return;
					}
					uni.getSetting({
						success: (res) => {
							let authStatus = false;
							switch (this.sourceTypeIndex) {
								case 0:
									authStatus = res.authSetting[
										'scope.camera'];
									break;
								case 1:
									authStatus = res.authSetting['scope.album'];
									break;
								case 2:
									authStatus = res.authSetting[
											'scope.album'] && res
										.authSetting['scope.camera'];
									break;
								default:
									break;

							}
							if (!authStatus) {
								uni.showModal({
									title: '授权失败',
									content: 'Hello uni-app需要从您的相机或相册获取图片，请在设置界面打开相关权限',
									success: (res) => {
										if (res.confirm) {
											uni.openSetting()
										}
									}
								})

							}
						}
					})
					// #endif
				}
			});
		},
		// 预览照片
		ViewImage(e, url) {
			uni.previewImage({
				urls: this.previewImg,
				current: e.currentTarget.dataset.url,
				loop: true,
				indicator: 'default'
			});
		},
		// 删除照片
		DelImg(e, id) {
			var that = this;
			uni.showModal({
				title: '召唤师',
				content: '确定要删除这段回忆吗？',
				cancelText: '再看看',
				confirmText: '再见',
				success: res => {
					if (res.confirm) {
						that.fromMsg.recordfiles.push({
							fId: id
						})
						this.imgList.splice(e.currentTarget.dataset.index, 1)
					}
				}
			})
		},
		// 选择视频 选择器
		sourceTypeChangechooseVideo() {
			var that = this
			uni.showActionSheet({
				title: '选择类型',
				itemList: this.videosourceType,
				success: e => {
					that.videosourceTypeIndex = e.tapIndex
					// 选择视频
					that.chooseVideo(that.videosourceTypeIndex)

				}
			});
		},
		// 选择视频
		chooseVideo: function(e) {
			let _this = this;
			uni.chooseVideo({
				sourceType: sourceType[e],
				maxDuration: 60,
				success: res => {
					uni.showLoading({
						title: '上传中',
						mask: true
					})
					var videoSrc = res.tempFilePath

					var uploadTask = uni.uploadFile({
						url: this.$http.uploadVideo,
						method: "POST",
						header: {
							'Authorization': 'bearer ' + uni.getStorageSync(
								'token')
						},
						formData: {
							folderid: _this.fromMsg.fSourcefile,
							userId: _this.userInfo.userId, // 当前登录用户的 id
							userName: _this.userInfo.realName,
						},
						filePath: videoSrc,
						name: 'file',
						success: (res) => {
							// 视频封面
							var imgSrc = JSON.parse(res.data)[0].atta
								.fFilepath
							var src;
							if (imgSrc.indexOf("mp4") != -1) {
								imgSrc = imgSrc.replace(/D:/,
									this.$http.file)
								src = imgSrc.replace(/mp4/, "jpg")
							} else {
								src =
									"https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E8%A7%86%E9%A2%91%E5%9B%BE%E7%89%87&step_word=&hs=0&pn=43&spn=0&di=119790&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&istype=2&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=-1&cs=3346960024%2C2036034045&os=4174661132%2C668644710&simid=0%2C0&adpicid=0&lpn=0&ln=1485&fr=&fmq=1626946136579_R&fm=result&ic=&s=undefined&hd=&latest=&copyright=&se=&sme=&tab=0&width=&height=&face=undefined&ist=&jit=&cg=&bdtype=0&oriquery=&objurl=https%3A%2F%2Fgimg2.baidu.com%2Fimage_search%2Fsrc%3Dhttp%3A%2F%2Fpic.vjshi.com%2F2017-02-23%2F812ed99eb35888901ff0e220bb05120c%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark%26refer%3Dhttp%3A%2F%2Fpic.vjshi.com%26app%3D2002%26size%3Df9999%2C10000%26q%3Da80%26n%3D0%26g%3D0n%26fmt%3Djpeg%3Fsec%3D1629538162%26t%3Df3acdf9335d81ccd4fbc9cdc305d8dc3&fromurl=ippr_z2C%24qAzdH3FAzdH3Fooo_z%26e3Be3fit_z%26e3Bv54AzdH3FowpviAzdH3Fl00cam_z%26e3Bip4s&gsm=&rpstart=0&rpnum=0&islist=&querylist=&nojc=undefined"
							}
							uni.hideLoading()
							let imgitem = {};
							imgitem.type = 'video';
							imgitem.id = JSON.parse(res.data)[0].atta.fId
							imgitem.src = src;
							imgitem.filePath = videoSrc;
							imgitem.needload = false;
							_this.fastImgLists.push(imgitem);
							if (_this.fastImgLists.length >= maxNum) {
								_this.canAdd = false;
							}
						},
						fail(res) {}
					})

					uploadTask.onProgressUpdate(function(res) {
						_this.pgList = res.progress;
						setTimeout(() => {
							_this.progress = false
						}, 1500)

					});
				},
				fail: (err) => {
					// #ifdef MP
					uni.getSetting({
						success: (res) => {
							let authStatus = false;
							switch (this.videosourceTypeIndex) {
								case 0:
									authStatus = res.authSetting[
										'scope.camera'];
									break;
								case 1:
									authStatus = res.authSetting[
										'scope.album'];
									break;
								case 2:
									authStatus = res.authSetting[
											'scope.album'] && res
										.authSetting['scope.camera'];
									break;
								default:
									break;
							}
							if (!authStatus) {
								uni.showModal({
									title: '授权失败',
									content: 'Hello uni-app需要从您的相机或相册获取视频，请在设置界面打开相关权限',
									success: (res) => {
										if (res.confirm) {
											uni.openSetting()
										}
									}
								})
							}

						}
					})
					// #endif
				}
			});
		},
		//移除
		delectVideo(e, id) {
			let _this = this;
			var index = e.currentTarget.id.replace('grace-items-img-', '');
			_this.fastImgLists.splice(index, 1);
			_this.fromMsg.recordfiles.push({
				fId: id
			})
			if (_this.fastImgLists.length < maxNum) {
				_this.canAdd = true;
			}
		},
		// 照片/视频






		// 连续扫码
		setInverted(index) {

			this.APPlist.splice(index, 1);
			var str = "";
			for (var i = 0; i < this.APPlist.length; i++) {
				str += this.APPlist[i] + ","
			}
			if (str.length > 0) {
				str = str.substr(0, str.length - 1);
			}
			this.fromMsg.fSampletestpiece = str;
		},
		scanCode(num) {

			if (num == 0) return false;
			var that = this
			var url = encodeURIComponent(window.location.href.split("#")[0]);
			this.$http.checkToken({
				url: url
			}).then(res => {
				let data = res.data;
				wx.config({
					debug: false,
					appId: data.appId,
					timestamp: data.timestamp,
					nonceStr: data.nonceStr,
					signature: data.signature,
					jsApiList: ["checkJsApi", "openLocation", "scanQRCode"],
					success(res) {
						console.log('nihao', res);

					}
				})
				wx.ready(function() {
					wx.checkJsApi({ //判断当前客户端版本是否支持指定JS接口
						jsApiList: ['scanQRCode'],
						success: function(
							res
						) { // 以键值对的形式返回，可用true，不可用false。如：{"checkResult":{"scanQRCode":true},"errMsg":"checkJsApi:ok"}
							if (res.checkResult.scanQRCode != true) {
								// uni.showToast({
								// 	title: "抱歉，当前客户端版本不支持扫一扫",
								// 	icon: 'none',
								// 	duration: 2000
								// });
							} else {
								wx.scanQRCode({
									needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
									scanType: ["qrCode",
										"barCode"
									], // 可以指定扫二维码还是一维码，默认二者都有
									success: function(res) {
										var result = res
											.resultStr; // 当needResult 为 1 时，扫码返回的结果
										// uni.showToast({
										// 	title: "微信调用扫一扫接口成功" + JSON
										// 		.stringify(result),
										// 	icon: 'none',
										// 	duration: 20000
										// });
										var datas = {
											fSampleuseno: result
										}
										that.$http
											.getSampleNoIsUse(
												datas).then(
												ress => {
													if (ress
														.errcode ==
														0) {
														if (ress
															.data ==
															true
														) {
															uni.showToast({
																title: "该编号已被使用",
																icon: 'none',
																duration: 2000
															})
														} else {
															that.timeId =
																setTimeout(
																	() => {
																		num--
																		that.scanCode(
																			num--
																		)
																	},
																	1500
																)
															that.ze
																.push(
																	result
																);
															that.ze =
																Array
																.from(
																	new Set(
																		that
																		.ze
																	)
																); //数组去重



															if (that
																.detatilId != ""
															) {

																var arr;
																if (that.fromMsg
																	.fSampletestpiece ==
																	""
																) {
																	arr = [];
																} else {
																	arr = that
																		.fromMsg
																		.fSampletestpiece
																		.split(
																			','
																		);
																}
																var newArr = arr
																	.concat(that
																		.ze);
																var d = Array
																	.from(
																		new Set(
																			newArr
																		));

																that.APPlist =
																	d;
																var str = "";
																for (var i =
																		0; i < d
																	.length; i++
																) {
																	str += d[
																			i] +
																		",";
																}

																if (str.length >
																	0) {
																	str = str
																		.substr(
																			0,
																			str
																			.length -
																			1);
																}
																that.fromMsg
																	.fSampletestpiece =
																	str;

															} else {
																// uni.showToast({
																// 	title: "222:",
																// 	icon: 'none',
																// 	duration: 2000
																// })

																that.APPlist =
																	that
																	.ze;

																var str =
																	"";
																for (
																	var i =
																		0; i <
																	that
																	.ze
																	.length; i++
																) {
																	str +=
																		that

																		.ze[
																			i
																		] +
																		",";

																}
																if (str
																	.length >

																	0
																) {
																	str =
																		str
																		.substr(
																			0,

																			str
																			.length -
																			1
																		);
																}
																that.fromMsg
																	.fSampletestpiece =
																	str;
															}
														}






													} else {
														console
															.log(
																'接口报错'
															)
													}
												})
										// that.$forceUpdate()

									},
									error: function(res) {
										if (res.errMsg
											.indexOf(
												'function_not_exist'
											) > 0) {
											uni.showToast({
												title: "版本过低请升级",
												icon: 'none',
												duration: 2000
											});
										}
									}


								})
							}
						},
						fail: function(res) { //检测getNetworkType该功能失败时处理
							alert('checkJsApi error');
						}
					}); //wx.checkJsApi结束
				})
				wx.error(function(res) {
					uni.showToast({
						title: "微信调用扫一扫接口报错" + JSON.stringify(res),
						icon: 'none',
						duration: 2000
					});
					// config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
				});
			})
		},
		// 连续扫码






		// wbs
		poinblur(e) {
			if (this.wbsRowData != null) {
				if (e.detail.value != this.wbsRowData.nameFull) {
					this.fromMsg.fProjectlocation = e.detail.value; //工程部位
					this.fromMsg.fProjectlocationid = ""; //工程部位id
				} else {
					this.fromMsg.fProjectlocation = this.wbsRowData.nameFull; //工程部位
					this.fromMsg.fProjectlocationid = this.wbsRowData.id; //工程部位id
				}
			}
		},
		getWbsToken() {
			var that = this
			that.$http.getWbsToken().then(res => {
				uni.setStorage({
					key: 'getWbsToken',
					data: JSON.stringify(res.data.Authorizations)
				});
				that.ProjectlocationFocus(that.userInfo.companyId, "");
			})
		},
		ProjectlocationFocus(id, num) {
			this.$refs.sevenqLazy._show(); //弹窗模式传递此操作参数
		},
		//接口报错返回
		error(e) {
			// console.log(e)
		},
		//点击确定返回
		confirmWbs(data) {
			var name = [];
			var id = [];
			var fLongids = [];
			data.map(item => {
				name.push(item.name);
				id.push(item.id);
				fLongids.push(item.fLongids)
			})
			this.fromMsg.fProjectlocation = name.join(','); //工程部位
			this.fromMsg.fProjectlocationid = id.join(','); //工程部位id
			this.fromMsg.fLocationid = fLongids.join(','); //工程部位id
			// console.log("confirmWbs", this.wbsRowData,e);
			// this.fromMsg.fProjectlocation = this.wbsRowData.nameFull; //工程部位
			// this.fromMsg.fProjectlocationid = this.wbsRowData.id; //工程部位id
		},
		//点击取消返回
		cancelWbs(e) {
			// console.log("cancelWbs", e)
		},
		//选择子级行数据
		wbsRow(row) {
			console.log("wbsRow", row);
			this.wbsRowData = row;
		},
		// wbs

	}
}
